package com.ruoyi.settled.controller;

import com.ruoyi.settled.domain.InfluencerOrders;
import com.ruoyi.settled.service.IInfluencerOrdersService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 博主订单Controller
 * 
 * @author huangchen
 * @date 2025-01-10
 */
@RestController
@RequestMapping("/InfluencerOrders/InfluencerOrders")
public class InfluencerOrdersController extends BaseController
{
    @Autowired
    private IInfluencerOrdersService influencerOrdersService;

    /**
     * 查询博主订单列表
     */
    @PreAuthorize("@ss.hasPermi('InfluencerOrders:InfluencerOrders:list')")
    @GetMapping("/list")
    public TableDataInfo list(InfluencerOrders influencerOrders)
    {
        startPage();
        List<InfluencerOrders> list = influencerOrdersService.selectInfluencerOrdersList(influencerOrders);
        return getDataTable(list);
    }

    /**
     * 导出博主订单列表
     */
    @PreAuthorize("@ss.hasPermi('InfluencerOrders:InfluencerOrders:export')")
    @Log(title = "博主订单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, InfluencerOrders influencerOrders)
    {
        List<InfluencerOrders> list = influencerOrdersService.selectInfluencerOrdersList(influencerOrders);
        ExcelUtil<InfluencerOrders> util = new ExcelUtil<InfluencerOrders>(InfluencerOrders.class);
        util.exportExcel(response, list, "博主订单数据");
    }

    /**
     * 获取博主订单详细信息
     */
    @PreAuthorize("@ss.hasPermi('InfluencerOrders:InfluencerOrders:query')")
    @GetMapping(value = "/{orderCode}")
    public AjaxResult getInfo(@PathVariable("orderCode") String orderCode)
    {
        return success(influencerOrdersService.selectInfluencerOrdersByOrderCode(orderCode));
    }

    /**
     * 新增博主订单
     */
    @PreAuthorize("@ss.hasPermi('InfluencerOrders:InfluencerOrders:add')")
    @Log(title = "博主订单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody InfluencerOrders influencerOrders)
    {
        return toAjax(influencerOrdersService.insertInfluencerOrders(influencerOrders));
    }

    /**
     * 修改博主订单
     */
    @PreAuthorize("@ss.hasPermi('InfluencerOrders:InfluencerOrders:edit')")
    @Log(title = "博主订单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody InfluencerOrders influencerOrders)
    {
        return toAjax(influencerOrdersService.updateInfluencerOrders(influencerOrders));
    }

    /**
     * 删除博主订单
     */
    @PreAuthorize("@ss.hasPermi('InfluencerOrders:InfluencerOrders:remove')")
    @Log(title = "博主订单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{orderCodes}")
    public AjaxResult remove(@PathVariable String[] orderCodes)
    {
        return toAjax(influencerOrdersService.deleteInfluencerOrdersByOrderCodes(orderCodes));
    }
}
